import popup from './popup.vue'
import {createVNode, render} from "vue";


const div = document.createElement('div')
div.setAttribute('class','popup')
document.body.appendChild(div)

export default function (){
  return new Promise((resolve,reject) => {
    //点击取消触发reject
    const cancelCallback = () => {
      reject('取消')
      render(null,div)
    }

    const submitCallback = () => {
      resolve('确定')
      render(null,div)
    }
    // createVNode的第二个参数可以给要渲染的组件传值
    const vNode = createVNode(popup,{cancelCallback,submitCallback})
    render(vNode,div)
  })
}
